
ALTER    PROCEDURE sp_get_price_for_rma_lineitem 

@PO_Number          varchar(50),
@PO_LineItem_Number int,
@Part_number        varchar(50)

AS
	
begin
	declare @result table(Unit_Price float)
	declare @salesorder_id int
	declare @product_id    int
	--declare @unit_price    numeric
	declare @unit_price    float -- Prabhanjan(May 6 2004)

	select  @salesorder_id =  salesorder_id from sales_order where so_customer_po_number = @PO_Number

	select 	@product_id =  Product.Product_ID
				from product,process_step 
				where product.processstep_id = process_step.processStep_id
				and PS_Type_Name like 'Finished Goods'
				and p_marketing_part_number =  @Part_number

	select  @unit_price = cool_unit_cost from customer_open_order_lineitem 
				where salesorder_id = @salesorder_id and product_id = @product_id and cool_po_line_item_no = @PO_LineItem_Number

	-- Prabhanjan (May 4 2004)
	IF(@unit_price IS NULL)
	BEGIN
		SET @unit_price = -1
	END

	insert into @result values(@unit_price)

	select unit_price from @result
end
